<!-- 赞赏 -->


	<div class="reward_area tc" id="js_reward_area" style="display: block;">
		<p class="tips_global reward_tips"><?php echo $article['zanshang_desc'];?></p>
		<p>
		
				<?php if(1 || !$is_pay || ($article['zanshang_type'] == 1)){?>
					<a class="reward_access" href="javascript:shang();" style="color: #fff;"><?php echo $article['zanshang_btn1'];?></a>
				<?php }else{ ?>
					<!--  <a class="reward_access"  style="color: #fff;background:#ccc;"><?php echo $article['zanshang_btn1'];?></a>-->
				<?php }?>
			
		</p>
		<div id="js_reward_inner" class="reward_area_inner"
			style="display: block;">
			<p class="tips_global reward_user_tips">
				<a href="javascript:void(0);" id="js_reward_total"><?php echo count($dslist);?></a>人已<?php echo $article['zanshang_btn1'];?>
				<?php if($article['zanshang_type'] == 1 && $is_pay){?>
					,你已赞赏
				<?php }else if($article['zanshang_type'] == 2 && $is_pay){ ?>
					,你已支付
				<?php }?>
			</p>
			<div class="reward_user_list tl">
			<?php foreach($dslist as $k=>$v){?>
				<span class="reward_user_avatar"><img src="<?php echo $v['headimgurl'];?>" onerror="javascript:this.src='__STATIC__mobile/images/logo.jpg';"></span>
			<?php } ?>
			</div>
		</div>
	</div>

<input value="<?php echo $article['zanshang_money'];?>" name="dashang_moeny" id="dashang_moeny" type="hidden">

<script>
function shang(){
	
	var article_id = "<?php echo $article['article_id'];?>";
	var money = $("#dashang_moeny").val();
	
	
	//alert(goods_id);
	var txt = '<div class="page_msg">'
		+'<div class="icon_area" style="margin-top:5px"><i class="p-article-avatar"><img src="<?php echo $touser['headimgurl'];?>" onerror="javascript:this.src=\'__STATIC__mobile/images/logo.jpg\';"></i></div>'
		+'<div class="text_area">'
			+'<h1 id="" class="title" style="font-size:16px;margin-top:10px">'+'<?php echo $article['zanshang_desc'];?>'+'</h1>'
			+'<p id="suc_desc" class="desc" style="margin-top:25px;">'+'<span style="font-size:40px;">'+money+'</span>'
			+'<em style="font-size:12px;">元</em></p>'
		//	+'<p style="font-size:12px;margin-top:10px;"><em >其他金额</em></p>'
			+'</div>'
		+'<div class="opr_area">'
			+'<a href="javascript:createshang('+article_id+');" class="mbtn btn-success btn-big "><?php echo $article['zanshang_btn2'];?><span style="font-size:12px;"></span></a></span>'
		+'</div>'
	+'</div>';
	//信息框

	
	//信息框
	layer.open({
	    title: ['请输入您的手机号码','display:none;'],
	    content: txt,
	  //  shade: false,
	    shadeClose: true,//点击遮罩是否关闭对话框
	    style: 'color:#fff;width:92%;max-width: 350px;background-color:#ea3b26;  background: url(/Static/mobile/img/ad.png) no-repeat;background-size:100%;',
	});
	
}



function createshang(article_id){
	
	var money = $("#dashang_moeny").val();
	if(!checkCurrency(money)){
		showerror("金额输入有误");
		return false;
	}
	
	if(money<=0){
		showerror("金额必须大于0");
		return false;
	}
	
	$.ajax({
		url : '/mobile/order/charge/?type=<?php echo $article['zanshang_type'];?>&article_id=<?php echo $article['article_id'];?>',
		type : 'post',
		data : {'money':money,'to_uid':'<?php echo $touser['uid'];?>'},
		dataType : 'json',
	//	async : false,
		success : function(data) {
			//关闭正在加载
			layer.closeAll();//关闭所有
			
			if(data.url){
				var urls = data.url;
			}else{
				var urls = '';
			}

			if(data.ret == 0){
				// 成功
				var order_id = data.url;
				jsApiCall2(data.data,order_id)
				
			}else{
				// 失败
				showerror(data.msg,urls);
			}
		},
		beforeSend:function(){
			//正在加载
			layer.open({
		        type: 2,
		        shade: true,
		        shadeClose: false,
		    });
			
       },
       error: function() {
		   //关闭正在加载
    	   layer.closeAll();//关闭所有
		   showerror("网络错误,请重试");
       }
       
	});
}


function jsApiCall2(jsparam,order_id)
{
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		jsparam,
		function(res){
			WeixinJSBridge.log(res.err_msg);
			 if(res.err_msg == "get_brand_wcpay_request:ok" ) {
			 	
				 //人数加1
				 var js_reward_total = $("#js_reward_total").text();
				 js_reward_total = parseInt(js_reward_total);
				 $("#js_reward_total").text(js_reward_total+1);
				 
				 //插入头像
				var html = '<span class="reward_user_avatar"><img src="<?php echo $memberinfo['headimgurl'];?>"></span>';
				$(html).prependTo(".reward_user_list");
				
				//弹窗感谢
				 showsuccess("感谢~么么哒");
				 
			  // location.href = "/mobile/order/payok/?order_id="+order_id;
			 
			 }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
			 
				//alert("未支付成功,请重试");
			 }
			//alert(res.err_msg);

		}
	);
}

</script>